{{ $site := site }}
{{ $treeCategory := treeCategory "* from category WHERE status in (1,2) order by status desc,sortNo desc" }}
{{ $content := selectList "content" "" 1 1000 "id,categoryID,title FROM content WHERE status in (1,2) order by status desc,sortNo desc" }}

{{template "base.html" }}
            <main class="container flex flex-even">
                <aside class="gdoc-nav">
                    <nav>
                        <div class="gdoc-search flex align-center">
                            <svg class="gdoc-icon gdoc_search">
                                <use xlink:href="#gdoc_search"></use>
                            </svg>
                            <input type="text" id="gdoc-search-input" class="gdoc-search__input" placeholder="Search..." aria-label="Search" maxlength="64" data-site-base-url="https://gitee.com/gpress/gpress-geekdoc" data-site-lang="en" />
                            <ul id="gdoc-search-results" class="gdoc-search__list"></ul>
                        </div>
                        <section class="gdoc-nav--main">
                            <h2>Navigation</h2>
                            <ul class="gdoc-nav__list">
                                {{ range $k,$v := $treeCategory }}
                                 
                                <li>
                                    {{$navCheck:=""}}
                                    {{if eq $k 0}}
                                      {{$navCheck = "checked" }}
                                    {{else if hasPrefix $.Id $v.Id}}
                                      {{$navCheck = "checked" }}
                                    {{end}}
                                    
                                    <input type="checkbox" class="gdoc-nav__toggle" id="navtree-{{$v.Id}}" {{$navCheck}} />
                                   
                                    {{if $v.HrefURL}}
                                    <label>
                                        <span class="flex">
                                            <a href="{{ hrefURL $v.HrefURL }}" class="gdoc-nav__entry">{{ $v.Name }}</a>
                                        </span>
                                    </label>
                                    {{ else }}
                                    <label for="navtree-{{$v.Id}}" class="flex justify-between align-center">
                                        <span class="flex">{{ $v.Name }}</span>
                                        <svg class="gdoc-icon toggle gdoc_keyboard_arrow_left">
                                            <use xlink:href="#gdoc_keyboard_arrow_left"></use>
                                        </svg>
                                        <svg class="gdoc-icon toggle gdoc_keyboard_arrow_down">
                                            <use xlink:href="#gdoc_keyboard_arrow_down"></use>
                                        </svg>
                                    </label>
                                    {{ end }}

                                    <ul class="gdoc-nav__list">
                                        {{if gt (len $v.Leaf) 0 }}
                                            {{ range $leafk,$leafv := $v.Leaf }}
                                            <li>
                                                <input type="checkbox" class="hidden">
                                                <label>
                                                    <span class="flex">
                                                        <a href="####" class="gdoc-nav__entry"> {{$leafv.Name}} </a>
                                                    </span>
                                                </label>
                                                <ul class="gdoc-nav__list">
                                                    {{ range $ck,$cv := $content.Data }}
                                                       {{if eq $leafv.Id $cv.CategoryID }}
                                                    <li>
                                                        <input type="checkbox" class="hidden" />
                                                        <label>
                                                            <span class="flex">
                                                                {{if eq $cv.Id $.Id}}
                                                                <a href="{{basePath}}{{ trimPrefixSlash $cv.Id}}" class="gdoc-nav__entry is-active">{{ $cv.Title }}</a>
                                                                {{else}}
                                                                <a href="{{basePath}}{{ trimPrefixSlash $cv.Id}}" class="gdoc-nav__entry">{{ $cv.Title }}</a>
                                                                {{end}}
                                                            </span>
                                                        </label>
                                                    </li>
                                                       {{end}}
                                                    {{end}}
                                                </ul>
                                            </li>
                                            {{end}}
                                        {{end}}

                                        <!-- 有内容就输出 -->
                                        {{ range $ck,$cv := $content.Data }}
                                            {{if eq $v.Id $cv.CategoryID }}
                                        <li>
                                            <input type="checkbox" class="hidden" />
                                            <label>
                                                <span class="flex">
                                                    {{if eq $cv.Id $.Id}}
                                                    <a href="{{basePath}}{{ trimPrefixSlash $cv.Id}}" class="gdoc-nav__entry is-active">{{ $cv.Title }}</a>
                                                    {{else}}
                                                    <a href="{{basePath}}{{ trimPrefixSlash $cv.Id}}" class="gdoc-nav__entry">{{ $cv.Title }}</a>
                                                    {{end}}
                                                </span>
                                            </label>
                                        </li>
                                           {{end}}
                                        {{end}}
                                    </ul>

                                 </li>
                                 {{ end }}
                            </ul>
                        </section>
                        <section class="gdoc-nav--more">
                            <h2>More</h2>
                            <ul class="gdoc-nav__list">
                                <li>
                                    <input type="checkbox" class="hidden" />
                                    <label>
                                        <span class="flex">
                                            <svg class="gdoc-icon gdoc_download">
                                                <use xlink:href="#gdoc_download"></use>
                                            </svg>
                                            <a href="https://gitee.com/gpress/gpress-geekdoc/releases" class="gdoc-nav__entry">Releases</a>
                                        </span>
                                    </label>
                                </li>
                                <li>
                                    <input type="checkbox" class="hidden" />
                                    <label>
                                        <span class="flex">
                                            <svg class="gdoc-icon gdoc_github">
                                                <use xlink:href="#gdoc_github"></use>
                                            </svg>
                                            <a href="https://gitee.com/gpress/gpress-geekdoc" class="gdoc-nav__entry">View Source</a>
                                        </span>
                                    </label>
                                </li>
                            </ul>
                        </section>
                    </nav>
                </aside>